﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.waitingQueue {
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class LoadWaitingPetCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var worldModel:WorldModel;
		[Inject]
        public var userModel:UserModel;

        override public function execute():void{
            this.loadAssets((this.event.info as Array));
        }
        private function loadAssets(_arg1:Array):void{
            var _local3:String;
            var _local4:WaitingVO;
            var _local2:RequestEvent = new RequestEvent(EventConstants.SEND_REQUEST, this.onResult);
            for each (_local4 in _arg1) {
                _local3 = ((_local4.disease.pet_name + "_") + _local4.disease.disease_name);
                _local2.addAssetRequest(ProtocolConstants.LOAD_PATIENT, _local3.toLowerCase());
            };
            dispatch(_local2);
        }
        private function onResult(_arg1:ResultVO):void{
            var _local2:Array;
            var _local3:WaitingVO;
            if (((_arg1.success) && (!(this.userModel.isVisitFriendsMode())))){
                _local2 = (this.event.info as Array);
                for each (_local3 in _local2) {
                    dispatch(new InfoEvent(EventConstants.CREATE_WAITING_PET, _local3.index.toString(), _local3.disease));
                };
            };
        }

    }
}//package net.wooga.pets.controllers.waitingQueue 
